package io.github.uicdb.et;

import com.google.common.collect.ImmutableMap;
import com.mojang.serialization.Codec;
import io.github.uicdb.et.attachment.EquippedTagHolder;
import io.github.uicdb.et.attachment.ReflectionCD;
import io.github.uicdb.et.net.ElementAttachmentData;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.attachment.AttachmentType;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NeoForgeRegistries;

import java.util.function.Supplier;

public class ModAttachments {
    private static final DeferredRegister<AttachmentType<?>> ATTACHMENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, ElementalTheory.MODID);
      public static final Supplier<AttachmentType<ReflectionCD>> REFLECTION_CD = ATTACHMENT_TYPES.register("reflection_cd", () -> AttachmentType.builder(() -> new ReflectionCD(ImmutableMap.of())).serialize(ReflectionCD.CODEC).build());
    public static final Supplier<AttachmentType<Float>> DEFENSE_ORB = ATTACHMENT_TYPES.register("defense_orb", () -> AttachmentType.builder(() -> 0f).serialize(Codec.FLOAT).build());
    public static final Supplier<AttachmentType<Float>> DEFENSE_ORB_SHADOW = ATTACHMENT_TYPES.register("defense_orb_shadow", () -> AttachmentType.builder(() -> 0f).serialize(Codec.FLOAT).build());
    public static final Supplier<AttachmentType<Integer>> LAST_ATTACK_TIME = ATTACHMENT_TYPES.register("last_attack_time", () -> AttachmentType.builder(() -> 0).serialize(Codec.INT).build());
    public static final Supplier<AttachmentType<EquippedTagHolder>> EQUIPPED_TAG_HOLDER = ATTACHMENT_TYPES.register("equipped_tag_holder", () -> AttachmentType.builder(() -> new EquippedTagHolder()).serialize(io.github.uicdb.et.attachment.EquippedTagHolder.CODEC).build());

    public static void init(IEventBus modBus) {
        ATTACHMENT_TYPES.register(modBus);
    }


}
